#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>

int main()
{
    pid_t id = fork();
    if(id ==0)
    {
        int i = 5;
        while(i)
        {
            printf("我是子进程,id=%d\n",getpid());
            i--;
            sleep(1);
        }
        exit(0);
    }
    //sleep(10);
    pid_t waitId = wait(NULL);
    if(waitId>0)
    {
        printf("父进程等待子进程（%d）\n",waitId);
    }
    return 0;
}

